﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <link href="~/layui/css/layui.css" rel="stylesheet" />
    <link href="~/layuimini/css/public.css" rel="stylesheet" />
    <style>
        td .layui-table-cell {
            height: 100px;
            line-height: 100px;
        }
    </style>
    <title>edit</title>
</head>
<body>
    <form id="mainForm" class="layui-form">
        <!-- 提示：如果你不想用form，你可以换成div等任何一个普通元素 -->
        @*<div class="layui-form-item">
                <label class="layui-form-label">ID</label>
                <div class="layui-input-block">
                    <input type="text" name="ID" id="ID" placeholder="请输入" autocomplete="off" class="layui-input">
                </div>
            </div>*@
        <div class="layui-form-item">
            <label class="layui-form-label">ID</label>
            <div class="layui-input-block">
                <input type="text" name="ID" id="ID" placeholder="请输入" autocomplete="off" class="layui-input" value="@ViewBag.ID">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">姓名</label>
            <div class="layui-input-block">
                <input type="text" name="Name" id="Name" placeholder="请输入" autocomplete="off" class="layui-input" value="@ViewBag.Name">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">电话</label>
            <div class="layui-input-block">
                <input type="tel" name="Phone" id="Phone" placeholder="输入手机号" autocomplete="off" class="layui-input" value="@ViewBag.Phone">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">请填写描述</label>
            <div class="layui-input-block">
                <input placeholder="请输入内容" Name="Remarks" id="Remarks" class="layui-input" value="@ViewBag.Remarks">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button id="tj" class="layui-btn" lay-submit lay-filter="GoAdd">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
        <!-- 更多表单结构排版请移步文档左侧【页面元素-表单】一项阅览 -->
    </form>
    <script src="~/layui/layui.js" charset="utf-8"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->
    <script>
 layui.use(['form', 'table'], function () {
     var $ = layui.jquery,
     form = layui.form,
     table = layui.table;

     //监听提交
     form.on('submit(GoAdd)', function (data) {
         
         $.ajax({
             url: '@Url.Action("AddUsersAsync", "Home")',
             type: 'post',
             dataType: 'json',
             //data: data.field,
             data: data.field,
             success: function (data) {
                 console.log(data);
                 //Info,Success,Warning,Error
                 var type = data.Type;
                 console.log(data.Type);
                 if (type == 1) {
                     layer.msg("添加成功", { icon: 1 },
                     //layer.msg(data.Content, { icon: 6, time: 2000 },
                         function () {
                             var Arry = parent.layer.getFrameIndex(window.name);
                             parent.layer.close(Arry);
                         });

                 } else {
                     layer.msg("修改成功", { icon: 1 },
                     //layer.msg(data.Content, { icon: 6, time: 2000 },
                         function () {
                             var Arry = parent.layer.getFrameIndex(window.name);
                             parent.layer.close(Arry);

                         });
                 }
             }

         });
         layer.alert(JSON.stringify(data.field), {
             title: '最终的提交信息'

         })
         return false;
         //return true;
     });

});
    </script>
</body>
</html>
